package com.example.lcode.greedy;

import java.util.ArrayList;
import java.util.List;

public class Question763 {

    public List<Integer> partitionLabels(String s) {
        List<Integer> res = new ArrayList<>();
        if (s == null || s.length() == 0) {
            return res;
        }
        int[] lastIndex = new int[26];
        for (int i = 0; i < s.length() ; i++) {
            lastIndex[s.charAt(i) - 'a'] = i;
        }
        int lastLength = -1;
        int max = 0;
        for (int i = 0; i < s.length(); i++) {
            max = Math.max(max, lastIndex[s.charAt(i) - 'a']);
            if (i == max) {
                res.add(i - lastLength);
                lastLength = i;
            }
        }
        return res;
    }

    public static void main(String[] args) {
        Question763 question763 = new Question763();
        List<Integer> ababcbacadefegdehijhklij = question763.partitionLabels("ababcbacadefegdehijhklij");
        System.out.println(1);
    }

}
